import numpy as np

class statisticsFactory():
    
    def __init__(self,inpop):
        self.pop=inpop.pool
    
    def average(self,index):
        ola=[]
        for i in self.pop:
            ola.append( i.data[index] )
        return np.mean(ola)
        #distinct=list(set(ola))
    
    def getPercentage(self,index):
        pass
    
    def getStats(self,index):     
        ola=[]
        for i in self.pop:
            ola.append( i.data[index] )
        distinct=list(set(ola))
        results=[]        
        stats={}
        for d in distinct:
            stats[d]= len(filter(lambda x: x==d, ola))
        results.append(stats)
        return results